﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YmtAuth.Domain.Model.Safe;
using YmtAuth.Domain.Repository.MySql;
using YmtAuth.Dto;

namespace YmtAuth.Domain.Repository
{
    public interface ISecurityQuestionRepository : IMySQLRepository<SecurityQuestion>
    {
        /// <summary>
        /// 获取安全问题列表
        /// </summary>
        /// <returns></returns>
        ResponseData<List<SecurityQuestion>> GetSecurityQuestionList();

        /// <summary>
        /// 设置安全问题
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        ResponseData<bool> SetSecurityQuestion(int userId, List<SecurityQuestionAnswer> list);

        /// <summary>
        /// 获取已设置的安全问题（单个，验证）
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="list"></param>
        /// <param name="nextVerifyDayCount"></param>
        /// <returns></returns>
        ResponseData<UserSecurityQuestion> GetSecurityQuestion(int userId, List<UserSecurityQuestion> list, int nextVerifyDayCount);

        /// <summary>
        /// 获取用户已设置的安全问题（多个）
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        List<UserSecurityQuestion> GetUserSecurityQuestion(int userId);

        /// <summary>
        /// 验证安全问题
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userQuestionId"></param>
        /// <param name="answer"></param>
        /// <returns></returns>
        ResponseData<bool> VerifySecurityQuestion(int userId, int userQuestionId, string answer);

        /// <summary>
        /// 获取用户当前的验证状态
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="nextVerifyDayCount"></param>
        /// <returns></returns>
        ResponseData<UserSecurityQuestionVerifyStatus> GetCurrentVerifyStatus(int userId, int nextVerifyDayCount);

        /// <summary>
        /// 对用户在最近一个时间周期的安全问题错误次数“清零”
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="nextVerifyDayCount"></param>
        /// <returns></returns>
        ResponseData<bool> ResetUserVerifyCount(int userId, int nextVerifyDayCount);

        /// <summary>
        /// 安全问题验证失败，更新最近一个时间周期内的验证日志的 更新时间（LastUpdateTime)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="nextVerifyDayCount"></param>
        /// <returns></returns>
        ResponseData<bool> VerifyFailHandle(int userId, int userQuestionId, string answer, int nextVerifyDayCount);
    }
}
